﻿using System;
using MetroIoc;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.Regions;
using SampleModule.Views;

namespace SampleModule
{
	public class MySampleModule : IModule
	{
		private readonly IRegionManager regionManager;
		private readonly IContainer container;

		public MySampleModule(IContainer container, IRegionManager regionManager)
		{
			if (container == null)
			{
				throw new ArgumentNullException("regionManager");
			}

			if (container == null)
			{
				throw new ArgumentNullException("regionManager");
			}

			this.container = container;
			this.regionManager = regionManager;
		}

		public void Initialize()
		{
			var mySampleView = this.container.Resolve<SampleView>();
			this.regionManager.Regions["MainRegion"].Add(mySampleView);
		}
	}
}